﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetFlow]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetFlow];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetFlow]
    @FlowID int =0
AS
BEGIN
SET NOCOUNT ON;

IF @FlowID>0
BEGIN
    SELECT
            A.Flow_ID,
            A.Flow_Name,
            CONVERT(nvarchar(10),A.Build_Date,120) Build_Date,
            A.Builder,
            A.Remark,
            A.Style_ID,
            B.Style_NAME
        FROM
            dbo.uds_flow a,
            dbo.uds_flow_style b
        WHERE
            a.style_id = b.style_id
            AND a.flow_id = @FlowID         
END
ELSE
BEGIN
    SELECT
            A.Flow_ID,
            A.Flow_Name,
            CONVERT(nvarchar(10),A.Build_Date,120) Build_Date,
            A.Builder,
            A.Remark,
            A.Style_ID,
            B.Style_NAME
        FROM
            dbo.uds_flow a,
            dbo.uds_flow_style b
        WHERE
            a.style_id = b.style_id
END;

END
GO